{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# pandas 进阶修炼 ｜早起Python\n",
    "<br>\n",
    "\n",
    "**本习题由公众号【早起Python & 可视化图鉴】 原创，转载及其他形式合作请与我们联系（微信号`sshs321`)，未经授权严禁搬运及二次创作，侵权必究！**\n",
    "\n",
    "\n",
    "\n",
    "本习题基于 `pandas` 版本 `1.1.3`，所有内容应当在 `Jupyter Notebook` 中执行以获得最佳效果。\n",
    "\n",
    "不同版本之间写法可能会有少许不同，如若碰到此情况，你应该学会如何自行检索解决。"
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 5 - 数据筛选与修改\n",
    "\n",
    "\n",
    "<br>\n",
    "\n",
    "现在，终于来到 `pandas` 数据分析中最**高频**的操作，没有之一————数据的`增删改查`\n",
    "\n",
    "在后面的分组、聚合、透视、可视化等多个操作中，数据的筛选、修改操作也会不断出现。\n",
    "\n",
    "因此在本章节，我整理了 40 余个常用操作\n",
    "\n",
    "以习题的形式，带大家回顾利用 `pandas` 进行数据的增删改查。\n",
    "\n",
    "需要注意的是，**本节中的大部分习题都有两个、三个或者更多的解法**，但我仅提供一个思路。\n",
    "\n",
    "我提供的并非唯一也并非最优的方法，欢迎大家集思广益，加入 pandas 星球来提交你的解答并获得一定奖励。\n",
    "\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 初始化\n",
    "\n",
    "<br>\n",
    "\n",
    "该 `Notebook` 版本为**纯习题版**\n",
    "\n",
    "如果需要答案或者提示，可以微信搜索公众号「早起Python」获取！"
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 加载数据"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 278,
   "source": [
    "import pandas as pd\r\n",
    "\r\n",
    "#df = pd.read_html(\"https://olympics.com/tokyo-2020/olympic-games/zh/results/all-sports/medal-standings.htm\")[0]\r\n",
    "\r\n",
    "df = pd.read_csv(\"东京奥运会奖牌数据.csv\")  # 如果未联网可以使用这条命令加载数据"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 5-1 数据修改\n",
    "\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 1- <font color = '#FB8E00'>数据修改</font>｜列名\r\n",
    "\r\n",
    "<br>\r\n",
    "\r\n",
    "将原 `df` 列名 `Unnamed: 2`、`Unnamed: 3`、`Unnamed: 4` 修改为 `金牌数`、`银牌数`、`铜牌数`"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 279,
   "source": [
    "df.rename(mapper={\"Unnamed: 2\": '金牌数', \"Unnamed: 3\": '银牌数', \"Unnamed: 4\": '铜牌数'}, axis=1, inplace=True)\r\n",
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>86</td>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>86</td>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>86</td>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>86</td>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>86</td>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1    美国   39   41   33  113      1     USA\n",
       "1    2    中国   38   32   18   88      2     CHN\n",
       "2    3    日本   27   14   17   58      5     JPN\n",
       "3    4    英国   22   21   22   65      4     GBR\n",
       "4    5   ROC   20   28   23   71      3     ROC\n",
       "..  ..   ...  ...  ...  ...  ...    ...     ...\n",
       "88  86    加纳    0    0    1    1     77     GHA\n",
       "89  86  格林纳达    0    0    1    1     77     GRN\n",
       "90  86   科威特    0    0    1    1     77     KUW\n",
       "91  86  摩尔多瓦    0    0    1    1     77     MDA\n",
       "92  86   叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 8 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 279
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 2 - <font color = '#FB8E00'>数据修改</font>｜行索引\n",
    "\n",
    "<br>\n",
    "\n",
    "将第一列（排名）设置为索引"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 280,
   "source": [
    "df.set_index('排名', inplace = True)\r\n",
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "排名                                         \n",
       "1     美国   39   41   33  113      1     USA\n",
       "2     中国   38   32   18   88      2     CHN\n",
       "3     日本   27   14   17   58      5     JPN\n",
       "4     英国   22   21   22   65      4     GBR\n",
       "5    ROC   20   28   23   71      3     ROC\n",
       "..   ...  ...  ...  ...  ...    ...     ...\n",
       "86    加纳    0    0    1    1     77     GHA\n",
       "86  格林纳达    0    0    1    1     77     GRN\n",
       "86   科威特    0    0    1    1     77     KUW\n",
       "86  摩尔多瓦    0    0    1    1     77     MDA\n",
       "86   叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 280
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3 - <font color = '#FB8E00'>数据修改</font>｜修改索引名\n",
    "\n",
    "<br>\n",
    "\n",
    "修改索引名为 金牌排名"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 281,
   "source": [
    "df.index.rename(\"金牌排名\" ,inplace = True)\r\n",
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国   39   41   33  113      1     USA\n",
       "2       中国   38   32   18   88      2     CHN\n",
       "3       日本   27   14   17   58      5     JPN\n",
       "4       英国   22   21   22   65      4     GBR\n",
       "5      ROC   20   28   23   71      3     ROC\n",
       "...    ...  ...  ...  ...  ...    ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA\n",
       "86    格林纳达    0    0    1    1     77     GRN\n",
       "86     科威特    0    0    1    1     77     KUW\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA\n",
       "86     叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 281
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 4 - <font color = '#FB8E00'>数据修改</font>｜修改值\n",
    "\n",
    "<br>\n",
    "\n",
    "将 ROC（第一列第五行）修改为 俄奥委会"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 282,
   "source": [
    "df.loc[5, '国家奥委会'] = '俄奥委会'\r\n",
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国   39   41   33  113      1     USA\n",
       "2       中国   38   32   18   88      2     CHN\n",
       "3       日本   27   14   17   58      5     JPN\n",
       "4       英国   22   21   22   65      4     GBR\n",
       "5     俄奥委会   20   28   23   71      3     ROC\n",
       "...    ...  ...  ...  ...  ...    ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA\n",
       "86    格林纳达    0    0    1    1     77     GRN\n",
       "86     科威特    0    0    1    1     77     KUW\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA\n",
       "86     叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 282
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 5 - <font color = '#FB8E00'>数据修改</font>｜替换值（单值）\n",
    "\n",
    "<br>\n",
    "\n",
    "将金牌数列的数字 `0` 替换为 `无`"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 283,
   "source": [
    "df.loc[df.金牌数 == 0, '金牌数'] = '无'\r\n",
    "data = df\r\n",
    "df\r\n"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会 金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                        \n",
       "1       美国  39   41   33  113      1     USA\n",
       "2       中国  38   32   18   88      2     CHN\n",
       "3       日本  27   14   17   58      5     JPN\n",
       "4       英国  22   21   22   65      4     GBR\n",
       "5     俄奥委会  20   28   23   71      3     ROC\n",
       "...    ...  ..  ...  ...  ...    ...     ...\n",
       "86      加纳   无    0    1    1     77     GHA\n",
       "86    格林纳达   无    0    1    1     77     GRN\n",
       "86     科威特   无    0    1    1     77     KUW\n",
       "86    摩尔多瓦   无    0    1    1     77     MDA\n",
       "86     叙利亚   无    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 283
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 6 - <font color = '#FB8E00'>数据修改</font>｜替换值（多值）\n",
    "\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "同时替换\r\n",
    "\r\n",
    "- 将 `无` 替换为 缺失值\r\n",
    "- 将 0 替换为 `None`\r\n",
    "\r\n",
    "注意：缺失值的 Nan 该怎么生成？"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 284,
   "source": [
    "df.replace({'无': pd.NA, 0: None},inplace=True)\r\n",
    "df\r\n"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会   金牌数   银牌数 铜牌数   总分 按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国    39    41  33  113     1     USA\n",
       "2       中国    38    32  18   88     2     CHN\n",
       "3       日本    27    14  17   58     5     JPN\n",
       "4       英国    22    21  22   65     4     GBR\n",
       "5     俄奥委会    20    28  23   71     3     ROC\n",
       "...    ...   ...   ...  ..  ...   ...     ...\n",
       "86      加纳  <NA>  None   1    1    77     GHA\n",
       "86    格林纳达  <NA>  None   1    1    77     GRN\n",
       "86     科威特  <NA>  None   1    1    77     KUW\n",
       "86    摩尔多瓦  <NA>  None   1    1    77     MDA\n",
       "86     叙利亚  <NA>  None   1    1    77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 284
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 285,
   "source": [
    "data.dtypes"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "国家奥委会      object\n",
       "金牌数        object\n",
       "银牌数        object\n",
       "铜牌数        object\n",
       "总分         object\n",
       "按总数排名      object\n",
       "国家奥委会代码    object\n",
       "dtype: object"
      ]
     },
     "metadata": {},
     "execution_count": 285
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 270,
   "source": [
    "pd.to_numeric(pd.NA)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "nan"
      ]
     },
     "metadata": {},
     "execution_count": 270
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 7 - 数据查看\n",
    "\n",
    "查看各列数据类型"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 286,
   "source": [
    "df.dtypes"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "国家奥委会      object\n",
       "金牌数        object\n",
       "银牌数        object\n",
       "铜牌数        object\n",
       "总分         object\n",
       "按总数排名      object\n",
       "国家奥委会代码    object\n",
       "dtype: object"
      ]
     },
     "metadata": {},
     "execution_count": 286
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 8 - <font color = '#FB8E00'>数据修改</font>｜修改类型\n",
    "\n",
    "将 `金牌数` 列类型修改为 `int`"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 291,
   "source": [
    "#df = df.convert_dtypes()\r\n",
    "df.fillna(0, inplace=True)\r\n",
    "df.astype({\"金牌数\": int})\r\n",
    "df.dtypes"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "国家奥委会      string\n",
       "金牌数         int64\n",
       "银牌数         Int64\n",
       "铜牌数         Int64\n",
       "总分          Int64\n",
       "按总数排名       Int64\n",
       "国家奥委会代码    string\n",
       "dtype: object"
      ]
     },
     "metadata": {},
     "execution_count": 291
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 292,
   "source": [
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国   39   41   33  113      1     USA\n",
       "2       中国   38   32   18   88      2     CHN\n",
       "3       日本   27   14   17   58      5     JPN\n",
       "4       英国   22   21   22   65      4     GBR\n",
       "5     俄奥委会   20   28   23   71      3     ROC\n",
       "...    ...  ...  ...  ...  ...    ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA\n",
       "86    格林纳达    0    0    1    1     77     GRN\n",
       "86     科威特    0    0    1    1     77     KUW\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA\n",
       "86     叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 292
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 9 - <font color = '#1B85FF' >数据增加</font>｜新增列（固定值）\n",
    "\n",
    "<br>\n",
    "\n",
    "**重新加载数据** 并 **新增一列** 比赛地点，值为 `东京`\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "source": [
    "df['比赛地点'] = '东京'"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "微信搜索公众号「早起Python」，关注后可以获得更多资源！"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "source": [
    "df.dtypes"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "国家奥委会      string\n",
       "金牌数        object\n",
       "银牌数         Int64\n",
       "铜牌数         Int64\n",
       "总分          Int64\n",
       "按总数排名       Int64\n",
       "国家奥委会代码    string\n",
       "比赛地点       object\n",
       "dtype: object"
      ]
     },
     "metadata": {},
     "execution_count": 173
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 10 - <font color = '#1B85FF' >数据增加</font>｜新增列（计算值）\n",
    "\n",
    "<br>\n",
    "\n",
    "**新增一列** 金银牌总数列，值为该国家金银牌总数"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "source": [
    "df['金银牌总数'] = pd.to_numeric(df.金牌数) + df.银牌数\r\n",
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数   银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数\n",
       "金牌排名                                                      \n",
       "1       美国   39    41   33  113      1     USA   东京   80.0\n",
       "2       中国   38    32   18   88      2     CHN   东京   70.0\n",
       "3       日本   27    14   17   58      5     JPN   东京   41.0\n",
       "4       英国   22    21   22   65      4     GBR   东京   43.0\n",
       "5     俄奥委会   20    28   23   71      3     ROC   东京   48.0\n",
       "...    ...  ...   ...  ...  ...    ...     ...  ...    ...\n",
       "86      加纳  NaN  <NA>    1    1     77     GHA   东京   <NA>\n",
       "86    格林纳达  NaN  <NA>    1    1     77     GRN   东京   <NA>\n",
       "86     科威特  NaN  <NA>    1    1     77     KUW   东京   <NA>\n",
       "86    摩尔多瓦  NaN  <NA>    1    1     77     MDA   东京   <NA>\n",
       "86     叙利亚  NaN  <NA>    1    1     77     SYR   东京   <NA>\n",
       "\n",
       "[93 rows x 9 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 174
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 11 - <font color = '#1B85FF' >数据增加</font>｜新增列（比较值）\n",
    "\n",
    "新增一列 最多奖牌数量 列，值为该过金银牌数量种最多的一个奖牌数量\n",
    "\n",
    "例如美国银牌最多，则为41，中国为38"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "df['最多奖牌数量'] = df.loc[:,['金牌数', '银牌数', '铜牌数']].max(axis=1)\r\n",
    "df"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "      <td>41.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "      <td>38.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "      <td>27.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "      <td>28.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>86</td>\n",
       "      <td>加纳</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>86</td>\n",
       "      <td>格林纳达</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>86</td>\n",
       "      <td>科威特</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>86</td>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>86</td>\n",
       "      <td>叙利亚</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名 国家奥委会   金牌数   银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数  最多奖牌数量\n",
       "0    1    美国    39    41   33  113      1     USA   东京     80    41.0\n",
       "1    2    中国    38    32   18   88      2     CHN   东京     70    38.0\n",
       "2    3    日本    27    14   17   58      5     JPN   东京     41    27.0\n",
       "3    4    英国    22    21   22   65      4     GBR   东京     43    22.0\n",
       "4    5   ROC    20    28   23   71      3     ROC   东京     48    28.0\n",
       "..  ..   ...   ...   ...  ...  ...    ...     ...  ...    ...     ...\n",
       "88  86    加纳  <NA>  <NA>    1    1     77     GHA   东京   <NA>     1.0\n",
       "89  86  格林纳达  <NA>  <NA>    1    1     77     GRN   东京   <NA>     1.0\n",
       "90  86   科威特  <NA>  <NA>    1    1     77     KUW   东京   <NA>     1.0\n",
       "91  86  摩尔多瓦  <NA>  <NA>    1    1     77     MDA   东京   <NA>     1.0\n",
       "92  86   叙利亚  <NA>  <NA>    1    1     77     SYR   东京   <NA>     1.0\n",
       "\n",
       "[93 rows x 11 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 138
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 12 - <font color = '#1B85FF' >数据增加</font>｜新增列（判断值）\n",
    "\n",
    "新增一列 金牌大于30\n",
    "\n",
    "如果一个国家的金牌数大于 30 则值为 是，反之为 否"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "df['金牌数大于30'] =  df.金牌数 > 30\r\n",
    "#df['金牌数大于30'].replace({True: '是', False: '否'},inplace=True)"
   ],
   "outputs": [
    {
     "output_type": "error",
     "ename": "TypeError",
     "evalue": "'>' not supported between instances of 'str' and 'int'",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_84396/2066951311.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'金牌数大于30'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m  \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m金牌数\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m30\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[1;31m#df['金牌数大于30'].replace({True: '是', False: '否'},inplace=True)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pandas\\core\\ops\\common.py\u001b[0m in \u001b[0;36mnew_method\u001b[1;34m(self, other)\u001b[0m\n\u001b[0;32m     67\u001b[0m         \u001b[0mother\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mitem_from_zerodim\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     68\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 69\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     70\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     71\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0mnew_method\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pandas\\core\\arraylike.py\u001b[0m in \u001b[0;36m__gt__\u001b[1;34m(self, other)\u001b[0m\n\u001b[0;32m     46\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0munpack_zerodim_and_defer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"__gt__\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     47\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__gt__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 48\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_cmp_method\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0moperator\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     49\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     50\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0munpack_zerodim_and_defer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"__ge__\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pandas\\core\\series.py\u001b[0m in \u001b[0;36m_cmp_method\u001b[1;34m(self, other, op)\u001b[0m\n\u001b[0;32m   5499\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   5500\u001b[0m         \u001b[1;32mwith\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merrstate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mall\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"ignore\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 5501\u001b[1;33m             \u001b[0mres_values\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mops\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcomparison_op\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mop\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   5502\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   5503\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_construct_result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mres_values\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mres_name\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pandas\\core\\ops\\array_ops.py\u001b[0m in \u001b[0;36mcomparison_op\u001b[1;34m(left, right, op)\u001b[0m\n\u001b[0;32m    282\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    283\u001b[0m     \u001b[1;32melif\u001b[0m \u001b[0mis_object_dtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlvalues\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 284\u001b[1;33m         \u001b[0mres_values\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcomp_method_OBJECT_ARRAY\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mop\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrvalues\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    285\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    286\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pandas\\core\\ops\\array_ops.py\u001b[0m in \u001b[0;36mcomp_method_OBJECT_ARRAY\u001b[1;34m(op, x, y)\u001b[0m\n\u001b[0;32m     71\u001b[0m         \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlibops\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvec_compare\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mravel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mravel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mop\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     72\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 73\u001b[1;33m         \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlibops\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscalar_compare\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mravel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mop\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     74\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     75\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pandas\\_libs\\ops.pyx\u001b[0m in \u001b[0;36mpandas._libs.ops.scalar_compare\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: '>' not supported between instances of 'str' and 'int'"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 13 - <font color = '#1B85FF' >数据增加</font>｜增加多列\n",
    "\n",
    "新增两列，分别是\n",
    "\n",
    "- 金铜牌总数（金牌数+铜牌数）\n",
    "- 银铜牌总数（银牌数+铜牌数）"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "df.dtypes"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "排名           Int64\n",
       "国家奥委会       string\n",
       "金牌数         object\n",
       "银牌数          Int64\n",
       "铜牌数          Int64\n",
       "总分           Int64\n",
       "按总数排名        Int64\n",
       "国家奥委会代码     string\n",
       "比赛地点        string\n",
       "金银牌总数        Int64\n",
       "最多奖牌数量     float64\n",
       "金牌数大于30    boolean\n",
       "dtype: object"
      ]
     },
     "metadata": {},
     "execution_count": 156
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 14 - <font color = '#1B85FF' >数据增加</font>｜新增列（引用变量）\n",
    "\n",
    "新增一列金牌占比，为各国金牌数除以总金牌数（gold_sum）"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 15 - <font color = '#1B85FF' >数据增加</font>｜新增行（末尾追加）\n",
    "\n",
    "<br>\n",
    "\n",
    "在 df 末尾追加一行，内容为 0,1,2,3... 一直到 `df` 的列长度"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 16 - <font color = '#1B85FF' >数据增加</font>｜新增行（指定位置）\n",
    "\n",
    "<br>\n",
    "\n",
    "在第 2 行新增一行数据，即美国和中国之间。\n",
    "\n",
    "数据内容同上一题"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 17 - <font color ='#27BE49'>数据删除</font>｜删除行\n",
    "\n",
    "<br>\n",
    "\n",
    "删除 `df` 第一行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 18 - <font color ='#27BE49'>数据删除</font>｜删除行（条件）"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 19 - <font color ='#27BE49'>数据删除</font>｜删除列\n",
    "\n",
    "<br>\n",
    "\n",
    "删除刚刚新增的 比赛地点 列"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 20 - <font color ='#27BE49'>数据删除</font>｜删除列（按列号）\n",
    "\n",
    "<br>\n",
    "\n",
    "删除 `df` 的 `7、8、9、10` 列"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 5-2 数据筛选\n",
    "\n",
    "以下所有答案要求返回的是一个 dataframe 而不是 Series 这样可以直接存储为 Excel 等格式的文件！"
   ],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 21 - 重新加载数据"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_html(\"https://olympics.com/tokyo-2020/olympic-games/zh/results/all-sports/medal-standings.htm\")[0]\n",
    "\n",
    "# df = pd.read_csv(\"东京奥运会奖牌数据.csv\")  # 如果未联网可以使用这条命令加载数据\n",
    "\n",
    "df.rename(columns={'Unnamed: 2':'金牌数',\n",
    "                  'Unnamed: 3':'银牌数',\n",
    "                  'Unnamed: 4':'铜牌数'},inplace=True)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "\n",
    "### 22 - <font color = '#FB8E00'>筛选列</font>｜通过列号\n",
    "\n",
    "提取第 1、2、3、4 列"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 23 - <font color = '#FB8E00'>筛选列</font>｜通过列名\n",
    "\n",
    "提取 `金牌数、银牌数、铜牌数` 三列"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 24 - <font color = '#FB8E00'>筛选列</font>｜条件（列号）\n",
    "\n",
    "筛选全部 **奇数列**"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 25 - <font color = '#FB8E00'>筛选列</font>｜条件（列名）\n",
    "\n",
    "提取全部列名中包含 数 的列"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 26 - <font color = '#FB8E00'>筛选列</font>｜组合（行号+列名）\n",
    "\n",
    "提取倒数后三列的10-20行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 27 - <font color = '#1B85FF' >筛选行</font>｜通过行号\n",
    "\n",
    "提取第 10 行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 28 -  <font color = '#1B85FF' >筛选行</font>｜通过行号（多行）\n",
    "\n",
    "提取第 10 行之后的全部行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 29 - <font color = '#1B85FF' >筛选行</font>｜固定间隔\n",
    "\n",
    "提取 0-50 行，间隔为 3"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 30 -  <font color = '#1B85FF' >筛选行</font>｜判断（大于）\n",
    "\n",
    "提取 金牌数 大于 30 的行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 31 -  <font color = '#1B85FF' >筛选行 </font>｜判断（等于）\n",
    "\n",
    "提取 `金牌数` 等于 10 的行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 32 - <font color = '#1B85FF' >筛选行</font>｜判断（不等于）\n",
    "\n",
    "提取 `金牌数` 不等于 `10` 的行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 33 - <font color = '#1B85FF' >筛选行</font>｜条件（指定行号）\n",
    "\n",
    "提取全部 **奇数行**\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 34 - <font color = '#1B85FF' >筛选行</font>｜条件（指定值）\n",
    "\n",
    "\n",
    "提取 中国、美国、英国 三行数据"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 35 -  <font color = '#1B85FF' >筛选行</font>｜多条件\n",
    "\n",
    "在上一题的条件下，新增一个条件：**金牌数小于30**"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 36 - <font color = '#1B85FF' >筛选行</font>｜条件（包含指定值）\n",
    "\n",
    "提取 国家奥委会 列中，所有包含 `国`的行"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 37 - 筛选某行某列\n",
    "\n",
    "提取 `第 0 行第 2 列`"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 38 - 筛选多行多列\n",
    "\n",
    "\n",
    "提取 第 0-2 行第 0-2 列\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 39 - <font color ='#27BE49'>筛选值</font>｜组合（行号+列号）\n",
    "\n",
    "提取第 4 行，第 4 列的值"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "###  40 - <font color ='#27BE49'>筛选值</font>｜组合（行号+列名）\n",
    "\n",
    "提取行索引为 4 ，列名为 金牌数 的值\n"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 41 - <font color ='#27BE49'>筛选值</font>｜条件\n",
    "\n",
    "提取 国家奥委会 为 中国 的金牌数"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 42 - <font color ='#27BE49'>筛选值</font>｜query\n",
    "\n",
    "使用 query 提取 金牌数 + 银牌数 大于 15 的国家"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "###  43 - <font color ='#27BE49'>筛选值</font>｜query（引用变量）\n",
    "\n",
    "使用 query 提取 金牌数 大于 金牌均值的国家"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "![](http://liuzaoqi.oss-cn-beijing.aliyuncs.com/2021/09/16/16317972442543.jpg?域名/sample.jpg?x-oss-process=style/stylename)"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.9.6 64-bit"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "367px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  },
  "interpreter": {
   "hash": "e4d85d63baa40a9854e1e91e14fde8d7f9b9a564a40f3bc91b58b47abf2bd79f"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}